home *** CD-ROM | disk | FTP | other *** search
- Path: lyra.csx.cam.ac.uk!news
- From: gdr11@cl.cam.ac.uk (Gareth Rees)
- Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++,comp.edu
- Subject: Re: ANSI C and POSIX (was Re: C/C++ knocks the crap out of Ada)
- Followup-To: comp.lang.c
- Date: 12 Apr 1996 12:26:26 +0100
- Organization: Cambridge University Computer Lab
- Message-ID: <yxsag0hel99.fsf@stint.cl.cam.ac.uk>
- References: <JSA.96Feb16135027@organon.com> <4kb2j8$an0@solutions.solon.com>
- <4kbrt5$k3h@mulga.cs.mu.OZ.AU> <dewar.829012486@schonberg>
- <4kcpgkINNcku@keats.ugrad.cs.ubc.ca>
- <TYNOR.96Apr9105114@twratl.atlanta.twr.com>
- <4kgunm$o4o@gde.GDEsystems.COM>
- NNTP-Posting-Host: stint.cl.cam.ac.uk
- In-reply-to: Chet's message of 10 Apr 1996 18:30:14 GMT
- X-Newsreader: Gnus v5.0.15
-
- Chet <kackman> wrote:
- > If i = j depends on your unit of address. If i is assumed a longword then
- >
- > &i + 4 = &j is true
- > not
- > &i + 1 = &j
-
- In the C language, the `unit of address' in address arithmetic depends
- on the type of the address on which the arithmetic happens. Go back and
- read section 5.4 of K&R2 again.
-
- $ uname -sr
- SunOS 4.1.3_U1
- $ cat arith.c
- #include <stdio.h>
- int main () {
- int i;
- printf("%p + 1 = %p\n", &i, &i+1);
- return 0;
- }
- $ gcc arith.c
- $ ./a.out
- f7fffa3c + 1 = f7fffa40
-
- Followups to comp.lang.c only.
-
- --
- Gareth Rees
-